function UserTreeObject() {
	var recordSize = 5;		//本页数据的条数 
	var currentCount = 0;	//本页已选择的条数
	var currentPage = 1;	//当前页
	var selectedOrg = "";	//选中的组织ID
	var pageIdArray = "";	//保存本页所有记录的ID
	var pageTextArray = "";	//保存本页所有记录的文本
	var userPageObject;
	var maxAhref = 0;
	var minAhref = 10000;
}
/*
*删除已选择项, 需作以下更新:
* 1) 更新人员列表checkbox的状态
* 2) 在'已选择的人'中删除对应的项
* 3) 更新全选项的状态
*/
UserTreeObject.prototype.deleteSelected = function (obj) {
	var ops = obj.options;
	var found = false;
	for (var n = 0; n < ops.length; ) {
		if (ops[n].selected == true) {
			if (this.userPageObject.document.getElementById("ck_" + ops[n].value) != null) {	//选中的值， 有可能不在该分布中
				this.userPageObject.document.getElementById("ck_" + ops[n].value).checked = false;
				getSubElement("userList", "ck_title").checked = false;
				this.currentCount--;
			}
			ops.remove(n);
			found = true;
		} else {
			n++;
		}
	}
	if(!found){
		//LoadingBar.showAlert("请选择需要删除的账号");
		alert('请选择需要删除的账号');
	}
};
/*
* 点击列表全选checkbox 触发action, 会作以下处理:
*	1  如果是选中, 判断每一行的checkbox是否已经选中
*		1)如果没有, 则为obj添加该项, 并将该行选中 
		2)如果选中, 则不作任何处理
	2  如果为未选中,  判断每一行的checkbox是否已经选中
		1)如果选中, 则obj删除该项, 并将该行改为未选中 
		2)如果未选中, 则不作任何处理
	3 重置计数器
*/
UserTreeObject.prototype.changeAll = function (obj, chec) {
	var val = this.pageIdArray;
	var tex = this.pageTextArray;
	if (chec) {	//选中
		var simpVa = val.split(",");
		var simpTe = tex.split(",");
		for (var k = 0; k < simpVa.length; k++) {
			if (this.userPageObject.document.getElementById("ck_" + simpVa[k]) != null && !this.userPageObject.document.getElementById("ck_" + simpVa[k]).checked) {	//如果本来已经选中, 则不需要作任何处理
				var op = document.createElement("option");
				op.value = simpVa[k];
				op.text = simpTe[k];
				obj.options.add(op);
				this.userPageObject.document.getElementById("ck_" + simpVa[k]).checked = true;
			}
		}
		this.initCountFull();		//将当页计数设为页记录条数
	} else {	//取消, 即未选中
		var ops = obj.options;
		var simpVa = val.split(",");
		for (var k = 0; k < simpVa.length; k++) {
			for (var n = 0; n < ops.length; ) {
				if (ops[n].value == simpVa[k]) {	//因removeoption对象之后, 后面的队列会覆盖其位置,所以没有n++
					obj.remove(n);
					if (this.userPageObject.document.getElementById("ck_" + simpVa[k]) != null) {
						this.userPageObject.document.getElementById("ck_" + simpVa[k]).checked = false;
					}
					break;
				} else {
					n++;
				}
			}
		}
		this.initCountClear();	//清空计数器
	}
};
UserTreeObject.prototype.changeThis = function (chec, val, tex) {
    var obj = document.getElementById("selectedPerson");
    var params = getParams();
    if (chec) {
        if (params && params["\"selectMode\""] == 'single') {
            document.getElementById("selectedPerson").innerHTML = '';
            var ops = window.frames['userList'].document.getElementsByName('ck_box');
            for (var n = 0; n < ops.length; n++) {
                if (ops[n].id != 'ck_' + val) {
                    ops[n].checked = false;
                    this.currentCount--;
                }
            }
        }
        var op = document.createElement("option");
        op.value = val;
        op.text = tex;
        obj.options.add(op);
        this.currentCount++;
        if (this.currentCount == this.recordSize) {
            getSubElement("userList", "ck_title").checked = true;
        }
    } else {
        var ops = obj.options;
        for (var n = 0; n < ops.length; n++) {
            if (ops[n].value == val) {
                ops.remove(n);
                getSubElement("userList", "ck_title").checked = false;
                this.currentCount--;
                return;
            }
        }
    }
};
UserTreeObject.prototype.submitSelect = function (obj) {
    var ops = obj.options;
    var selectedObject = [];
    var selectedValue = "";
    var selectedText = "";
    for (var n = 0; n < ops.length; n++) {
        var text = ops[n].text;
        var index = text.lastIndexOf("[");
        text = text.substring(0, index);
        selectedText += text + ",";
        selectedValue += ops[n].value + ",";
    }
    if (selectedValue.length > 0 && selectedText.length > 0) {
        selectedObject[0] = selectedValue.substr(0, selectedValue.length - 1);
        selectedObject[1] = selectedText.substr(0, selectedText.length - 1);
    }
    return selectedObject;
};
UserTreeObject.prototype.initSelection = function (obj) {
	var ops = obj.options;
	var nn = 0;
	for (var n = 0; n < ops.length; n++) {
		if (this.userPageObject.document.getElementById("ck_" + ops[n].value) != null) {	//选中的值， 有可能不在该分布中
			this.userPageObject.document.getElementById("ck_" + ops[n].value).checked = true;
			nn += 1;
		}
	}
	if (nn > 0 && n == this.recordSize) {
		getSubElement("userList", "ck_title").checked = true;
	} else {
		getSubElement("userList", "ck_title").checked = false;
	}
};
UserTreeObject.prototype.queryUserList = function (obj) {
	var ops = obj.options;
	for (var n = 0; n < ops.length; n++) {
		if (this.userPageObject.document.getElementById("ck_" + ops[n].value) != null) {	//选中的值， 有可能不在该分布中
			this.userPageObject.document.getElementById("ck_" + ops[n].value).checked = true;
		}
	}
};
UserTreeObject.prototype.initCountClear = function () {
	this.currentCount = 0;
};
UserTreeObject.prototype.initCountFull = function () {
	this.currentCount = this.recordSize;
};
UserTreeObject.prototype.setRecordSize = function (va) {
	this.recordSize = va;
};
UserTreeObject.prototype.getRecordSize = function () {
	return this.recordSize;
};
UserTreeObject.prototype.getCurrentPage = function () {
	return this.currentPage;
};
UserTreeObject.prototype.setCurrentPage = function (va) {
	this.currentPage = va;
};
UserTreeObject.prototype.getSelectedOrg = function () {
    return this.selectedOrg;
};
UserTreeObject.prototype.setSelectedOrg = function (va) {
    this.selectedOrg = va;
};
UserTreeObject.prototype.resetPage = function (va, tex) {
	this.pageIdArray = va;	//保存本页所有记录的ID
	this.pageTextArray = tex;	//保存本页所有记录的文本
};
UserTreeObject.prototype.setUserListPage = function (obj) {
	this.userPageObject = obj;	//保存用户列表的页面对象 
};
function getSubElement(frameId, objId) {
	return window.frames[frameId].document.getElementById(objId);
}

////////////////////// 辅助函数  ////////////////////////
function isDigit(s) {
	var patrn = /^[0-9]{1,20}$/;
	if (!patrn.exec(s)) {
		return false;
	}
	return true;
}

